package com.sharer.last.controller;

import com.sharer.last.base.constant.CommonConstant;
import com.sharer.last.base.model.PageVO;
import com.sharer.last.base.model.R;
import com.sharer.last.model.dto.log.ExceptionLogQueryDTO;
import com.sharer.last.model.vo.log.ExceptionLogVO;
import org.springframework.web.bind.annotation.*;
import com.sharer.last.service.ExceptionLogService;

import javax.annotation.Resource;

/**
 * 异常日志后台管理
 *
 * @ClassName ExceptionLogController
 * @Author wangjin
 * @Date 2023/5/5 21:03
 * @Description
 * @Version 1.0
 */
@RestController
@RequestMapping(CommonConstant.BLOG_ADMIN_API + "/exception/log")
public class ExceptionLogController {
	@Resource
	ExceptionLogService exceptionLogService;

	/**
	 * 分页查询异常日志列表
	 *
	 * @param exceptionLogDTO
	 * @return
	 */
	@PostMapping("/page")
	public R<PageVO<ExceptionLogVO>> page(@RequestBody ExceptionLogQueryDTO exceptionLogDTO) {
		PageVO<ExceptionLogVO> pageList = exceptionLogService.selectListByPage(exceptionLogDTO);
		return R.success(pageList);
	}

	/**
	 * 按id删除异常日志
	 *
	 * @param id 日志id
	 * @return
	 */
	@DeleteMapping("/delete")
	public R delete(@RequestParam Long id) {
		exceptionLogService.removeExceptionLogById(id);
		return R.handle();
	}
}
